<!-- quirks mode -->
<body>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<dialog>
<button class="nextButton"></button>
<button class="nextButton"></button>
</dialog>
<template><div></div></template>
<script>
test(function() {
  var dialog = document.querySelector('dialog');
  var button = dialog.querySelector('.nextButton');
  var templateDocument = document.querySelector('template').content.ownerDocument;

  // Preconditions
  assert_equals(document.compatMode, 'BackCompat')
  assert_equals(templateDocument.compatMode, 'CSS1Compat');

  templateDocument.adoptNode(button);
  assert_not_equals(dialog.querySelector('.nextButton'), null);
}, 'Moving an element with a class attribute from a quirks-mode document to a standard-mode document should not affect class matching.');
</script>
</body>
